﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Input;
using t01crm.Data;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Windows.Controls.Ribbon;

namespace t01crm.View
{
    public class RibbonItem : RibbonCommand
    {
        public ICommand _actualCommand; 
        public ICommand ActualCommand 
        {

            get
            {
                return _actualCommand; 
            }
            set
            {
                if (_actualCommand != value)
                {
                    _actualCommand = value;
                    OnPropertyChanged("ActualCommand");

                    if (_actualCommand != null)
                    {
                        this.CanExecute += new CanExecuteRoutedEventHandler(RibbonItem_CanExecute);
                        this.Executed += new ExecutedRoutedEventHandler(RibbonItem_Executed);                         
                    }
                    else
                    {
                        this.CanExecute -= new CanExecuteRoutedEventHandler(RibbonItem_CanExecute);
                        this.Executed -= new ExecutedRoutedEventHandler(RibbonItem_Executed); 
                    } 
                } 
            }           
        }

        void RibbonItem_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (_actualCommand != null)
            {
                _actualCommand.Execute(e.Parameter); 
            } 
        }

        void RibbonItem_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (_actualCommand != null)
            {
                e.CanExecute = _actualCommand.CanExecute(e.Parameter);
                e.Handled = true; 
            } 
        }
          

        protected void OnPropertyChanged(string propertyName)
        {
            //INotifyPropertyChanged inpc = this as INotifyPropertyChanged; 
            
 
            //PropertyChangedEventHandler ph =  inpc.PropertyChanged;
            //if (ph != null)
            //    ph(this, new PropertyChangedEventArgs(propertyName));
        }


    } 

    public class RibbonItem2 : BusinessEntity 
    {
        protected string _labelDescription; 
        public string LabelDescription 
        {
            get { return _labelDescription; }
            set {                
                if (value != _labelDescription)
                {
                    _labelDescription = value;
                    OnPropertyChanged("LabelDescription");
                } 
            } 
        }

        protected string _labelTitle;         
        public string LabelTitle
        {
            get { return _labelTitle; }
            set { _labelTitle = value; OnPropertyChanged("LabelTitle"); }
        }

        protected ImageSource _largeImageSource;
        public ImageSource LargeImageSource
        {
            get { return _largeImageSource; }
            set
            {
                if (value != _largeImageSource)
                {
                    _largeImageSource = value;
                    OnPropertyChanged("LargeImageSource");
                }
            }                 
        } 

       
        protected ImageSource _smallImageSource;
        public ImageSource SmallImageSource
        {
            get { return _smallImageSource; }
            set
            {
                if (value != _smallImageSource)
                {
                    _smallImageSource = value;
                    OnPropertyChanged("SmallImageSource");
                }
            }
        }

        protected string _toolTipDescription; 
        public string ToolTipDescription         
        {
            get { return _toolTipDescription; }
            set
            {
                if (value != _toolTipDescription)
                {
                    _toolTipDescription = value;
                    OnPropertyChanged("ToolTipDescription");
                }
            }
        }

        protected string _toolTipFooterDescription;
        public string ToolTipFooterDescription
        {
            get { return _toolTipFooterDescription; }
            set
            {
                if (value != _toolTipFooterDescription)
                {
                    _toolTipFooterDescription = value;
                    OnPropertyChanged("ToolTipFooterDescription");
                }
            }
        }

        protected ImageSource _tooltipFooterImageSource;
        public ImageSource ToolTipFooterImageSource
        {
            get { return _tooltipFooterImageSource; }
            set
            {
                if (value != _tooltipFooterImageSource)
                {
                    _tooltipFooterImageSource = value;
                    OnPropertyChanged("TooltipFooterImageSource");
                }
            }
        }


        protected string _toolTipFooterTitle;
        public string ToolTipFooterTitle
        {
            get { return _toolTipFooterTitle; }
            set
            {
                if (value != _toolTipFooterTitle)
                {
                    _toolTipFooterTitle = value;
                    OnPropertyChanged("ToolTipFooterTitle");
                }
            }
        }

        public ImageSource ToolTipImageSource { get; set; }


        protected string _toolTipTitle;
        public string ToolTipTitle
        {
            get { return _toolTipTitle; }
            set
            {
                if (value != _toolTipTitle)
                {
                    _toolTipTitle = value;
                    OnPropertyChanged("ToolTipTitle");
                }
            }
        }
 
        protected ICommand _command; 

        public ICommand Command
        {
            get
            {
                return _command; 
            }
            set
            {
                ICommand old = _command; 
                _command = value;
                if (_command != old)
                    OnPropertyChanged("Command"); 
            } 
        } 
    }
}
